<!--{include header}-->
<style text="text/css">
.l{float:left;}
.r{float:right;}
.edit{width:360px;}
.resout{position:relative;width:220px;}
.skin-box{margin-top:10px;}
.tit{text-align:right;width:90px;}
.nr{line-height:30px;}
.wid-wid,.wid-hei{border-color:#C4C7BD #F2F2F2 #F2F2F2 #C4C7BD;border-style:solid;border-width:1px;padding:2px;vertical-align:middle;width:60px;}
.source-box{border-top:1px dashed #CCCCCC;margin-top:30px;}
</style>
<div class="wrap">
<div class="uleft c3" id="uleft_ev56">
    <h2 id="helptit"><a href="/help/tour.php">帮助中心</a></h2>
    <ul>${current_help('widget')}</ul>
</div>

  <div class="uright" id="uright_ev56">
    <div class="utit">
      <h2>团购挂件</h2>
    </div>
    <div class="acon">      
      <div class="sect">
				     <div class="l edit">
					   <h6 style="display:inline">请选择城市 ：</h6><select id="switchcity" name="city_id" class="f-city">${Utility::Option(Utility::OptionArray($allcities, 'id', 'name'), $city['id'])}</select>
					   <div class="skin-box">
		                   <div class="l tit">尺寸：</div>
						   <div class="l nr">
							宽度
							<input id="wid-city" class="wid-wid" type="text" value="180">
							<input id="no-width" type="checkbox" style="vertical-align:middle" value="" name="">
							自动调整宽度
							<br />
							高度
							<input id="hei-city" class="wid-hei" type="text" value="400">
							</div>
					   </div>
					   <div class="clear"></div>
					   <div style="padding:5px;text-align:center">
					   <input id="show-city-widget" class="btn-fz" type="button" style="width:200px;padding:3px;height:30px" value="预览并生成代码">
					   </div>
					   <div class="source-box">
					       <h6>获得HTML代码</h6>
						   <span class="zi-hui">请复制下面的代码，粘贴到博客的自定义模块中。</span>
						   <textarea id="invite-textarea" style="width:360px;height:110px" rows="" cols="" name="textarea"></textarea>
					   </div>
					   <div style="padding:5px;">
					   <input class="btn-fz" type="button" style="width:100px;padding:3px;height:30px" value="复制代码" onclick="copyCode('invite-textarea');$('#invite-textarea')[0].select();">
					   </div>
					 </div>

					 <div id="show-wid" class="r resout" style="height:100px">
					 <iframe id="zt-widget" width="180" scrolling="auto" height="355" frameborder="0" style="position:absolute;left:0;top:0;" src="widget.php">
					 </iframe>
					 </div>
					 <div class="clear"></div>
				</div>
      
    </div>
  </div>
  <div class="clear"></div>
  <a href="#header" id="gotop">返回顶部</a>
</div>
<script type="text/javascript">
$(function(){
    var wikiurl = window.location.protocol+"//"+window.location.host;
	var minheight = 150;
	$('#no-width').click(function(){
		if($(this).attr('checked') == true){
			$('.wid-wid').attr('disabled',true);
		}else{
			$('.wid-wid').attr('disabled',false);
		}
	});

	$('#show-city-widget').click(function(){
		var cityid = $('#switchcity').val();
		var width = '';
		var height = '';
		var src1 = '';
		var iff = '';
		if(!($('#no-width').attr('checked'))){
			width = $('#wid-city').val();
			if(width <180){
				alert('宽度建议不要低于180像素');
				$('#wid-city').val('180');
				return ;
			}else if(isNaN(width)){
				$('#wid-city').val('180');
				return ;
			}else if(width>900){
				alert('宽度建议不要大于900像素');
				$('#wid-city').val('900');
				return ;
			}
		}
		height = $('#hei-city').val();
		if(height<minheight){
			alert('高度建议不要低于'+minheight+'像素');
			$('#hei_city').val(minheight);
			return ;
		}else if(isNaN(height)){
			$('#hei_city').val(minheight);
			return ;	
		}else if(height>800){
			alert('高度建议不大于800像素');
			$('#hei_city').val('800');
			return;
		}

		if($('#no-width').attr('checked')){
			src1 = wikiurl+WEB_ROOT+'/widget.php?'+'cityid='+cityid+'&width=180&height='+height;
			$('#zt-widget').removeAttr('src').attr('src',src1).removeAttr('height').attr('height',(parseInt(height)+4)).removeAttr('width').attr('width','180');
			iff = "<iframe id='zt-widget' width=180 height="+(parseInt(height)+4)+" style='position:absolute;left:0;top:0;' frameborder='0' scrolling='auto' src='"+src1+"'></iframe>";
		}else{
			src1 = wikiurl+WEB_ROOT+'/widget.php?'+'cityid='+cityid+'&width='+width+'&height='+height;
			$('#zt-widget').removeAttr('src').attr('src',src1).removeAttr('height').attr('height',(parseInt(height)+4)).removeAttr('width').attr('width',width);
			iff = "<iframe id='zt-widget' width="+width+" height="+(parseInt(height)+4)+" style='position:absolute;left:0;top:0;' frameborder='0' scrolling='auto' src='"+src1+"'></iframe>";
		}
		$('#invite-textarea').empty().val(iff);
	});

});
</script>
<script type="text/javascript"> 
function copyCode(id){ 
    var testCode=document.getElementById(id).value; 
    if(copy2Clipboard(testCode)!=false){ 
        alert("生成的代码已经复制到粘贴板，你可以使用Ctrl+V 贴到需要的地方去了哦！ "); 
    } 
} 
copy2Clipboard=function(txt){ 
    if(window.clipboardData){ 
        window.clipboardData.clearData(); 
        window.clipboardData.setData("Text",txt); 
    } 
    else if(navigator.userAgent.indexOf("Opera")!=-1){ 
        window.location=txt; 
    } 
    else if(window.netscape){ 
        try{ 
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
        } 
        catch(e){ 
            alert("您的firefox安全限制限制您进行剪贴板操作，请打开'about:config'将signed.applets.codebase_principal_support'设置为true'之后重试，相对路径为firefox根目录/greprefs/all.js"); 
            return false; 
        } 
        var clip=Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard); 
        if(!clip)return; 
        var trans=Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable); 
        if(!trans)return; 
        trans.addDataFlavor('text/unicode'); 
        var str=new Object(); 
        var len=new Object(); 
        var str=Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString); 
        var copytext=txt;str.data=copytext; 
        trans.setTransferData("text/unicode",str,copytext.length*2); 
        var clipid=Components.interfaces.nsIClipboard; 
        if(!clip)return false; 
        clip.setData(trans,null,clipid.kGlobalClipboard); 
    } 
} 
</script>
<!--{include footer}-->
